-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spanish translation #1130
Spanish translation #1130
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🎉
@@ -5,3 +5,4 @@ prune ci | |||
prune exe | |||
prune installer | |||
prune workbench | |||
include src/natcap/invest/internationalization/locales/*/LC_MESSAGES/messages.mo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know we could include globs here! Very cool.
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:192 | ||
msgid "" | ||
"Use user-defined local recharge data instead of calculating local " | ||
"recharge from the other provided data." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:195 | ||
msgid "user-defined recharge layer (advanced)" | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:205 | ||
msgid "" | ||
"Map of local recharge data. Required if User-Defined Local Recharge is " | ||
"selected." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:208 | ||
msgid "local recharge" | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:212 | ||
msgid "Use user-defined climate zone data in lieu of a global rain events table." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:215 | ||
msgid "climate zones (advanced)" | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:222 | ||
msgid "" | ||
"Climate zone ID numbers, corresponding to the values in the Climate Zones" | ||
" map." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:228 | ||
msgid "" | ||
"The number of rain events that occur in each month in this climate zone. " | ||
"Replace [MONTH] with the month abbreviations: jan, feb, mar, apr, may, " | ||
"jun, jul, aug, sep, oct, nov, dec, so that there is a column for each " | ||
"month." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:236 | ||
msgid "" | ||
"Table of monthly precipitation events for each climate zone. Required if " | ||
"User-Defined Climate Zones is selected." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:239 | ||
msgid "climate zone table" | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:246 | ||
msgid "" | ||
"Map of climate zones. All values in this raster must have corresponding " | ||
"entries in the Climate Zone Table." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:249 | ||
msgid "climate zone map" | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:253 | ||
msgid "Use montly alpha values instead of a single value for the whole year." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:256 | ||
msgid "use monthly alpha table (advanced)" | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:264 | ||
msgid "Values are the numbers 1-12 corresponding to each month." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:271 | ||
msgid "The alpha value for that month." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:275 | ||
msgid "" | ||
"Table of alpha values for each month. Required if Use Monthly Alpha Table" | ||
" is selected." | ||
msgstr "" | ||
|
||
#: src/natcap/invest/seasonal_water_yield/seasonal_water_yield.py:278 | ||
msgid "monthly alpha table" | ||
msgstr "" | ||
|
||
# Spanish translations for InVEST. | ||
# Copyright (C) 2022 Natural Capital Project | ||
# This file is distributed under the same license as the InVEST project. | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022. | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: InVEST 3.12\n" | ||
"Report-Msgid-Bugs-To: jdouglass@stanford.edu\n" | ||
"POT-Creation-Date: 2022-10-21 13:17-0700\n" | ||
"PO-Revision-Date: 2022-11-19 17:42-0500\n" | ||
"Last-Translator: \n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the Last-Translator
be Patricio's email?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I don't think any of these fields are required but I'll fill in his email
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: InVEST 3.12\n" | ||
"Report-Msgid-Bugs-To: jdouglass@stanford.edu\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall why my email is here ... @emlys would you like this to be your email? Or maybe we should have it email the software team email list, or else an alias at naturalcapitalproject.org
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @emlys , this is awesome. I reviewed the whole thing.
One thing I noticed when testing it out is that the Workbench strings are not translating, and I'm not sure how that is supposed to work exactly. And strangely, there is a test that tests for that, which somehow passes.
Other than that, I just a few minor comments.
workbench/src/renderer/app.jsx
Outdated
ipcRenderer.invoke( | ||
ipcMainChannels.SET_LANGUAGE, settings.language | ||
).then(() => saveSettingsStore(settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally it's the same, but for consistency across the codebase, how do you feel about using async/await
here instead of chaining the .then
calls?
I realize we're not 100% consistent on this -- we tend to use .then/.catch
for fetch
calls such as in server_requests.js
(for no particular reason), but I'd prefer to migrate towards async/await
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
@@ -876,6 +873,7 @@ describe('Translation', () => { | |||
|
|||
beforeAll(async () => { | |||
getInvestModelNames.mockResolvedValue({}); | |||
getSupportedLanguages.mockResolvedValue({ en: 'english', es: 'spanish' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a comment about the test in this block, which didn't actually have any changes...
I think it would be best to mock window.location.reload()
also. jsdom has a global window
, but I see a console error saying Error: Not implemented: navigation (except hash changes)
on the reload call.
Also in that test, it looks like we test that some workbench strings were translated (as opposed to invest strings) and those checks pass despite the browser refresh not happening, which I think makes sense? But if I use the workbench and change the language, I don't see those workbench strings translated. So I'm not exactly sure what's going on there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're not on the latest commit, you might also be missing the message catalog for the workbench strings, hence it's defaulting to English. The translation test mocks the message catalog, so I'd expect it to pass either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emlys I've confirmed that I have the latest changes, including the workbench message catalog and a fresh install, but I still can't get the workbench strings to translate. I also tried building a production version and don't get the translated strings there either. I confirmed this function is called with the correct & complete messageCatalogPath
, so I'm not sure how to debug further.
function loadMessageCatalogs() {
// load each language's message catalog PO file into an object
// for easy access when we switch languages
const languages = fs.readdirSync(`${__dirname}/../static/internationalization/locales`);
if (languages) {
languages.forEach((language) => {
const messageCatalogPath = `${__dirname}/../static/internationalization/locales/${language}/LC_MESSAGES/messages.po`;
console.log(messageCatalogPath)
i18n.loadJSON(readMessageCatalog(messageCatalogPath), 'messages');
});
}
logger.debug('loaded message catalogs');
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed now - the language code in the PO file was wrong, resulting in the messages not being used.
I agree it's not important to test that. Though I think that basic approach would work if |
I've spent a few hours on this now and can't get it to work. The mock doesn't work, and the test doesn't pass. If it's important to mock this maybe we can debug it together, otherwise, I don't think it's worth the effort to test. |
@emlys I've been there.
I'd be happy to work through it together. I don't think it's important to test whether |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @emlys, this looks awesome! And thanks Dave for giving this a thorough look and helping debug!
Hey @emlys, I just loaded up the Workbench and tried switching to Spanish. I just had a few quick questions and sorry if they've already been addressed.
So cool to see it in action! |
@davemfish I think I finally fixed the window reload mocking issue. I had to |
@emlys Thanks for figuring that out! I guess |
Description
This PR introduces our first translation of InVEST into Spanish:
expected tasks
bug fixes
ui_server.py
ui_server.py
triggered a weird bug where the test suite would hang indefinitely, on unrelated tests, and only when running most of the tests all together (could not reproduce with an individual test suite). It was fixed by moving the unit registry definition to its own module so thatu
isn't redefined when we reloadspec_utils
.pytest
command, rather than record as a test failure. I moved those imports into each individual test like we do for other models.small enhancement
We now get the list of supported languages and their localized names from the backend, rather than defining them in the workbench.
notes
I tried to test that the page reloads when the language is changed, following this example, but it didn't work and I didn't think it was that important.
There is also a PR in the works for the user's guide translation, but I don't think those need to be linked to this PR.
Checklist
Updated the user's guide (if needed)Tested the affected models' UIs (if relevant)